package tech.aistar.mapper;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import tech.aistar.entity.Com;

import javax.validation.constraints.Max;
import java.util.ArrayList;
import java.util.List;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
public class UserInfoMapperTest {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Autowired
    private PostMapper postMapper;

    @Test
    public void testsel(){
        System.out.println(userInfoMapper.findById(1));
        System.out.println("========================");
        System.out.println(userInfoMapper.findByUid("15776547495"));
    }
    @Test
    public void testAdd(){
        userInfoMapper.addUserInfo(13,"1013","鹰眼");
        System.out.println("---------------------------------------------");
        System.out.println(userInfoMapper.findById(12));
    }

    @Test
    public void findTest(){
        System.out.println(userInfoMapper.findById(1));
        System.out.println(userInfoMapper.findByUid("15776547495"));
    }

    @Test
    public void editTest(){
 //       userInfoMapper.editUserInfo("卜","2019-02-01 22:22:22",0,"牡丹江","明天放假了","http://fangjiale.com",11);
        System.out.println(userInfoMapper.findById(11));
    }

    @Test
    public void addTest(){
//        userInfoMapper.addUserInfo(2,"1001","索大");
//        userInfoMapper.addUserInfo(4,"1003","山治");
//        userInfoMapper.addUserInfo(6,"1005","罗宾");
//        userInfoMapper.addUserInfo(7,"1006","弗兰奇");
        userInfoMapper.addUserInfo(10,"1008","乌索普");


        //System.out.println(userInfoMapper.findById(11));
    }

    @Test
    public void addAny(){
        //添加邮箱 手机
        userInfoMapper.addEmail("www.22015345@qq.com",11);
        userInfoMapper.addPhone("15789562314",11);
//        userInfoService.addView();
        System.out.println(userInfoMapper.findById(11));
    }

    @Test
    public void calAnyInfo(){
        //增加粉丝数各种的.......   用户id在前  各种数量在后面
        userInfoMapper.calPost(1,11);
        userInfoMapper.calFans(1,11);
        System.out.println(userInfoMapper.findById(1));
    }
    @Test
    public void comm(){
        List<Com> com = userInfoMapper.findAllByUserId(1);
        List<String> Titlelist = new ArrayList<>();
        for (Com c:com){
            String t = postMapper.findPostByPostId(c.getPostId()).getTitle();
            Titlelist.add(t);
        }
        System.out.println(Titlelist.size());

    }
}
